# Author: HZT
# Date: 2023/10/22
import time
import page
from base.base import Base
from utils import click_paste_img


class WebCkLj(Base):
    # 点击卡图链接管理
    def ck_lj_click_ktlj(self):
        self.base_click(page.web_ck_lj_ktljgl)

    # 获取卡图页面
    def ck_lj_get_ktljym(self):
        return self.base_find(page.web_ck_lj_ktljym)

    # 点击新增
    def ck_lj_click_xz(self):
        self.base_click(page.web_ck_lj_xz)

    # 获取新增元素
    def ck_lj_get_xz(self):
        return self.base_find(page.web_ck_lj_xz)

    # 输入卡密
    def ck_lj_input_km(self, text):
        self.base_input(page.web_ck_lj_km, text)

    # 输入面额
    def ck_lj_input_me(self, text):
        self.base_input(page.web_ck_lj_me, text)

    # 输入卡密
    def ck_lj_input_bz(self, text):
        self.base_input(page.web_ck_lj_bz, text)

    # 卡图元素
    # 输入卡密
    def ck_lj_get_kt(self):
        return self.base_find(page.web_ck_lj_kt)

    # 点击提交
    def ck_lj_click_tj(self):
        self.base_click(page.web_ck_lj_tj)

    # 获取卡密列表
    def ck_lj_get_kmlb(self):
        return self.base_get_text(page.web_ck_lj_kmlb)

    # 获取面额列表
    def ck_lj_get_melb(self):
        return self.base_get_text(page.web_ck_lj_melb)

    # 获取网址列表
    def ck_lj_get_wzlb(self):
        return self.base_get_text(page.web_ck_lj_wzlb)

    # 获取备注列表
    def ck_lj_get_bzlb(self):
        return self.base_get_text(page.web_ck_lj_bzlb)

    # 获取查看卡图链接
    def ck_lj_get_ckktlj(self):
        return self.base_find(page.web_ck_lj_ckktlj)

    # 获取查看卡密元素
    def ck_lj_get_ckkm(self, km):
        return page.create_ck_lj_ckkm_selector(km)

    # 获取查看面额元素
    def ck_lj_get_ckme(self, me):
        return page.create_ck_lj_ckme_selector(me)

    # 组合新增业务
    def ck_lj_xz(self, driver, km, me, bz, filename=None):
        self.ck_lj_input_km(km)
        self.ck_lj_input_me(me)
        self.ck_lj_input_bz(bz)
        if filename:
            click_paste_img(filename, self.ck_lj_get_kt(), driver)
        self.ck_lj_click_tj()
